Lab 0: Introduction to Computer Vision Course

wellcome to Afeka's 3rd cycle of Computer Vision Course. TBD

Couse Overview:

Course Staff:

Dr. Eyal Katz, lecturer
eyalk@afeka.ac.il

Avi Mor, TA:
AviMor5@gmail.com

Ido Meroz, TA:
IdoMe@afeka.ac.il

Background

local envs vs colab

It's common to work either on a local machine or on a portable machine on the clound.

It's up to you to chose to work either with google colab or with a local environment manged using anaconda / miniconda. (refer to the installation guide) The Common providers of portable machines are:

  1. Amazon - AWS
  2. Google - Cloud / Colab
  3. Microsoft - Azure

Installation Guide Anaconda local environment

TODOs

if you are working locally you can ignore this section and skip to imports.

farther reading about linking colab and google drive

Imports

import required libraries for this notebook.

Loading an Image


in order to load an image using opencv the method imread is used with the relative path name of the image to be loaded.

Let's see some info about the image:

BGR vs RGB

different libraries assumes different order of channels.
in the code cell below it's demonstrated that open-cv loads the image with the following channels order: Blue Green Red, while matplotlib assumes a channel order of Red Green Blue.

Your turn:

modifiy the cell below to display the difference between channels order

Color represntation

Open-cv allows to switch between color represatation using it's cvtColor method.

This method will be used to convert the demo_image channel representation from BGR2RGB.

Your turn:

convert the color representation of the image you chose in the previous section from BGR to RGB

Color Image Vs Grayscale Image:

in this section you will see how to convert a color image to a grayscale image and display them with titles side by side

Load Images with PIL

different imgage processing libraries might represent images diffrently from each other. In the cell beolw we will compare between PIL and open-cv.

While open-cv uses np array to represent an image, PIL has it's own way of representing images.

As you can see PIL keeps track of the way the format in which is the image has been saved with in the machine memory

Final Report :

  1. install anaconda / miniconda, create virtual env and install with conda the following libraries: numpy, open-cv, matplotlib and PIL
  2. Load the messi's image(pressented below) as a color image
  3. Using open-cv draw methods to draw rectangles around messi and around the ball
  4. Using open-cv add text above each rectangle you had drawn in the previous exercise to describing the content of rectangle
  5. Append empty row below / above the image of messi
  6. Add text in the empy area you added to describe the image (bouns for creativity)
  7. Convert the image you have read with numpy to PIL format
  8. Read the zebra imge (presented below) with PIL resize(how ever you chose to) it's dimensions to be two times smaller and convert it to numpy format (the format opencv uses to represent images)
    The tasks has to be made with the virtual env you created. the last cell of your submmited lab should be:

import sys
print(sys.executable)

Messi's Image

messi.jpg

Zebra's Image

zebra.jpg